﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Zoomtel.Auth.Mvc.Attributes;
using Zoomtel.Entity.BIZ;
using Zoomtel.Persist.BIZ.Models;
using Zoomtel.Service.BIZ.ViewModels;

using Zoomtel.Service.BIZ;
using Zoomtel.Web.Controllers;
using Zoomtel.Service.Auth;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace Zoomtel.Web.Areas.Pub.Controllers
{
    [Description("分销商接口")]
    public class AgentController : PubModuleController
    {
        Service.BIZ.AgentInfoService _service;
        public AgentController(Service.BIZ.AgentInfoService service) 
        {
            _service = service;

        }


        [HttpGet]
        [AllowAnonymous]
        [Description("绑定注册2")]
        public Task<IResultModel> RegisterBind2()
        {
            AgentBindRegisterModel model = new AgentBindRegisterModel();
            model.Captcha = "48967";
            //model.Code = "081gp50w3MIwaW2OHa1w3wkX151gp50S";
            model.Phone = "15673146148";
            var result = _service.RegisterBind(model);
            return result;
        }


        [HttpPost]
        [AllowAnonymous]
        [Description("绑定注册")]
        public Task<IResultModel> RegisterBind(AgentBindRegisterModel model)
        {

            var result = _service.RegisterBind(model);
            return result;
        }



        [HttpPost]
        [Description("解除绑定")]
        public Task<IResultModel> UnBind()
        {

            var result = _service.UnBind();
            return result;
        }

        [HttpGet]
        [Description("登陆子分销商账户")]
        public async Task<IResultModel<UserTokenResult>> LoginByChildrenUid(string ChildrenUid)
        {
            var result = await _service.LoginByChildrenUid(ChildrenUid);

            return result;
        }


        [HttpGet]
        [AllowAnonymous]
        [Description("根据code获取token")]
        public async Task<IResultModel<UserTokenResult>> LoginByCode(string code)
        {
           var result=await _service.LoginByCode(code);

            return result;
        }

        [HttpGet]
        [Description("获取分销商信息")]
        public Task<IResultModel<AgentInfoPubModel>> GetUserInfo()
        {


            return _service.GetUserInfo("");
        }
        [AllowAnonymous]
        [HttpGet]
        [Description("获取分销商信息2")]
        public Task<IResultModel<AgentInfoPubModel>> GetUserInfo1()
        {


            return _service.GetUserInfo("5");
        }
        //[AllowAnonymous]
        [HttpPost]
        [Description("申请提现")]
        public Task<IResultModel> CashApply(decimal num)
        {
            return _service.CashApply(num);
        }

        [AllowAnonymous]
        [HttpGet]
        [Description("收益排行")]
        public Task<IResultModel> ProfitRank()
        {
            return _service.GetAgentProfitRank();

        }

        [HttpGet]
        [Description("获取子分销商列表")]
        public Task<IResultModel> GetChildrenAgent()
        {


            return _service.GetChildrenAgent();

        }

        //[HttpGet]
        //[Description("获取分销商钱包信息")]
        //public Task<IResultModel<AgentInfoEntity>> GetWalletInfo()
        //{


        //    return _service.GetUserInfo();
        //}
        //[HttpPost]
        //[Description("获取分销商信息")]
        //public Task<IResultModel> GetUserInfo()
        //{


        //    return null;
        //}

    }
}
